/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package mathma.core.vector;

import mathma.core.expr.Expression;

import mathma.core.form.BinaryExpression;

import mathma.core.value.Value;

/**
 * @since 0.2.6
 * @author Ethan Levine
 */
public class VectorProjectionExpression<E extends Value>
        extends BinaryExpression<Vector<E>, Vector<E>> {

    public VectorProjectionExpression(Expression<Vector<E>> firstOperand,
            Expression<Vector<E>> secondOperand) {
        super(Vector.GenericType, firstOperand, secondOperand);
    }

    public Vector<E> evaluate() {
        return getFirstOperand().evaluate().projectionAlong(
                getSecondOperand().evaluate());
    }

    public VectorProjectionExpression<E> newBinaryExpression(
            Expression<Vector<E>> first, Expression<Vector<E>> second) {
        return new VectorProjectionExpression<E>(first, second);
    }
}
